﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibMinecraft.Model;
using LibMinecraft.Server;

namespace PartyCraftServer.Commands
{
    public class KickCommand : Command
    {
        public override bool RequiresOp
        {
            get { return true; }
        }

        public override string DefaultCommand
        {
            get { return "kick"; }
        }

        public override string Documentation
        {
            get { return "Forcibly removes a player from the server.\nUsage: /kick [player] (message)\nIf provided, (message) is shown to the player."; }
        }

        public override void ExecuteCommand(RemoteClient client, params string[] parameters)
        {
            if (parameters.Length == 0 || parameters.Length > 2)
            {
                client.SendChat(ChatColor.Red + "Invalid parameters.  Use /kick [player] (message)");
                return;
            }
            if (PartyCraft.Server.GetClient(parameters[0]) == null)
            {
                client.SendChat(ChatColor.Red + "That player is not online.");
                return;
            }
            string msg = PartyCraft.Settings["server.messages.kick"];

            if (parameters.Length == 2)
                msg = parameters[1];

            PartyCraft.Server.KickPlayer(parameters[0], msg);
        }
    }
}
